package com.ssy.lingxi.order.controller.paas;

import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.order.api.model.vo.paas.OrderPayChannelFeignVO;
import com.ssy.lingxi.order.api.model.vo.paas.OrderRuleFeignVO;
import com.ssy.lingxi.order.service.paas.IOrderConfigService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * 订单服务配置接口
 * @author 万宁
 * @version 2.0.0
 * @date 2021-08-04
 */
@RestController
@RequestMapping("/order/config")
public class OrderConfigController {
    @Resource
    private IOrderConfigService orderConfigService;

    /**
     * 同步更新平台规则配置
     * @param rules 接口参数
     * @return 更新结果
     */
    @RequestMapping(value = "/base/rule", method = RequestMethod.POST)
    public Wrapper<Void> updateOrInsertOrderRules(@RequestBody @Valid List<OrderRuleFeignVO> rules) {
        return orderConfigService.updateOrInsertOrderRules(rules);
    }

    /**
     * 同步更新支付方式与支付渠道状态
     * @param payChannels 接口参数
     * @return 更新结果
     */
    @RequestMapping(value = "/base/pay/channel", method = RequestMethod.POST)
    public Wrapper<Void> updateOrderPayChannelStatus(@RequestBody @Valid List<OrderPayChannelFeignVO> payChannels) {
        return orderConfigService.updateOrderPayChannelStatus(payChannels);
    }
}
